- if ::Gitlab::CurrentSettings.custom_project_templates_enabled?
  - project_template_count = current_user.available_custom_project_templates.count
  - group_id = params[:namespace_id]

  .project-templates-buttons
    = gl_tabs_nav({ class: 'nav-links scrolling-tabs gl-display-flex gl-flex-grow-1 gl-flex-nowrap gl-border-0' }) do
      = gl_tab_link_to '#built-in', tab_class: 'built-in-tab', class: 'active', data: { toggle: 'tab' } do
        = _('Built-in')
        = gl_tab_counter_badge Gitlab::ProjectTemplate.all.count + Gitlab::SampleDataTemplate.all.count
      = gl_tab_link_to '#custom-instance-project-templates', tab_class: 'custom-instance-project-templates-tab', class: 'js-custom-instance-project-templates-nav-link', data: { toggle: 'tab', qa_selector: 'instance_templates_tab' } do
        = _('Instance')
        = gl_tab_counter_badge(project_template_count, { data: { qa_selector: 'instance_template_tab_badge_content' } })
      = gl_tab_link_to '#custom-group-project-templates', tab_class: 'custom-group-project-templates-tab', class: 'js-custom-group-project-templates-nav-link', data: { toggle: 'tab', qa_selector: 'group_templates_tab' } do
        = _('Group')
        = gl_tab_counter_badge(group_project_templates_count(group_id), { data: { qa_selector: 'group_template_tab_badge_content' } })

  .tab-content
    .project-templates-buttons.import-buttons.tab-pane.active#built-in
      = render partial: 'projects/project_templates/template', collection: Gitlab::ProjectTemplate.all + Gitlab::SampleDataTemplate.all
    .project-templates-buttons.import-buttons.tab-pane.js-custom-instance-project-templates-tab-content#custom-instance-project-templates{ data: {initial_templates: user_available_project_templates_path(current_user)} }
      = gl_loading_icon(size: 'md', css_class: 'gl-mt-4')
    .project-templates-buttons.import-buttons.tab-pane.js-custom-group-project-templates-tab-content#custom-group-project-templates{ data: {initial_templates: user_available_group_templates_path(current_user, group_id: group_id)} }
      = gl_loading_icon(size: 'md', css_class: 'gl-mt-4')

  .project-fields-form
    = render 'projects/project_templates/project_fields_form'
    = f.hidden_field(:use_custom_template, value: false)
    = f.hidden_field(:group_with_project_templates_id, value: nil, class: 'js-project-group-with-project-templates-id')
    = render 'projects/new_project_fields', f: f, project_name_id: "template-project-name", hide_init_with_readme: true, track_label: "create_from_template"

- else
  = render_ce 'projects/project_templates', f: f
